<?php
/**
 * 系统主框架以及公共显示区域
 * @author Bruce
 * time 2014-10-30
 */
namespace apps\fzq\controllers;
use libraries\RedisSession;
if( !APP_ROOT  )
    return 'Direct Access Deny!';
    
class TestController extends \Phalcon\Mvc\Controller
{
    /**
     * @comment( value = '' )
     */
	public function initialize()
	{
	    
	}
	
	
	
	public function x3Action()
	{
		echo __FILE__, __LINE__, '<br>';
// 		$t = microtime( true );
		
// 		$msg = $this->rqueue->getMsgProto( var_export( $_SERVER, true ),
// 				'aaaa',
// 				'bbbb' );
		
// 				for( $i = 0; $i < 10000; ++$i )
		
// 		 $this->rqueue->push( $msg );
// 		$t = microtime( true );
// 		for( $i = 0; $i < 1000; ++$i ) 
// 		 $this->seasLog->debug( var_export( $_SERVER, true ) );
		
// 		echo microtime( true ) - $t, '<br>';
// 		var_dump( $this->seasLog->log( SeasLogEnums::SEASLOG_INFO, 'asdfasfd' ));
// 		echo __METHOD__, '<br>';
	}
	public function sidAction()
	{
	      echo __FILE__, '<br>';
	    
	      $redis = $this->di->get( 'nredis' );
// 	      var_dump( get_class_methods( get_class($redis )));
// 	     var_dump( $redis->set( 'b', 'asdf', 'asdf' ));

// 	      var_dump( $redis->set( 'a3', 'b' ));
	      
// 	      var_dump( $redis->get( 'a3' ));
	      
// 	      var_dump( $redis->hSet( 'b3', 'b', 'bb' ));
// 	      var_dump( $redis->hGet( 'b3', 'b' ));
// echo __FILE__, '<br>';
// 	     var_dump( $redis->hget( 'b', 'asdf'));
// 	      var_dump( $_COOKIE );
// 	      return;
	      $r = new RedisSession( $redis );
	      
// 	     var_dump( $r->set("name","sdf4"));
// 	      var_dump( $r->set("age",1234));
	      
	      
	      var_dump( $r->get( 'name' ));
	}

	public function xAction()
	{
// 	    var_dump( serialize( 'asdfads'));
// 	    var_dump(unserialize( serialize( 'asdfads') ));
// // 	    var_dump( $this->session->getId(), '<br>');
//         var_dump( $this->session->set( 'asdf', 'aaaaaaaaa' ));
//         $this->session->start();
//         var_dump( $this->session );
//             var_dump( $this->session->start());
var_dump( $this->session->set( 'arr', array( 1=> 2, 2=> 3 ) ));
        var_dump( $this->session->get( 'arr' ) );
        
//         var_dump( 
//             $this->session , '<br>');
$obj = new \stdClass();
$obj->a = 3;
$obj->b = 4;
var_dump( $this->session->set( 'obj', $obj ));


	}
	
	public function x2Action()
	{
	    var_dump( $this->session->get( 'arr' ) );
	    
	    var_dump( $this->session->get( 'obj' ));
// 	    var_dump( $this->session->getId(), '<br>');
	    
// 	    var_dump( $this->session , '<br>');
	}
	
	public function sid2Action()
	{
	    $redis = $this->di->get( 'nredis' );
	    $r = new RedisSession( $redis );
	    var_dump( $r->get( 'name' ));
	}
	
	public function grandsAction()
	{
	    $_SESSION[ 'abc' ] = '1230';
	    
// 	    $this->session->set( 'sss', '1230' );
	    
	    var_dump( $_SESSION[ 'abc' ] );
// 	    $_SESSION['x'] = 'xxxxxxxxxxxxxxxx';
// 	    var_dump(class_exists( "\Phalcon\Session\Adapter\Redis" ));
//         var_dump( $this->nredis->hSet( 'a', 'b', 'dddd' ) );
//         var_dump( $this->nredis->hGet( 'a', 'b' ) );
//         echo '<br />--------------------<br />';
//         var_dump( $this->session->set( 'abc' , 'def' ) );
//         var_dump( $this->session->get( 'abc' ) );
         
	}
	
	public function tAction()
	{
		echo __METHOD__, '<br>';		
	}
	
	public function rAction()
	{
		$this->view->disable();
		$this->dispatcher->forward( array( 'controller' => 'test', 'action' => 't' ));
	}
	
	public function rdAction()
	{
		$this->response->redirect( 'fzq/test/t' );
	}
	
}
